﻿using System.ComponentModel.DataAnnotations;
using AutoMapper;
using BaseAPI.BaseModel;
using Microsoft.EntityFrameworkCore;

namespace BaseAPI.BaseViewModel;

public class BasePatchViewModel<T> where T : BaseEntity, new()
{
    [Required] public long ID { get; set; }

    IMapper _mapper;

    public void Init(IMapper mapper)
    {
        _mapper = mapper;
    }

    public virtual T GetT()
    {
        return new T
        {
            ID = ID
        };
    }

    public virtual void PatchFun(T t, DbContext dbContext)
    {
        _mapper.Map(this, t);
    }
}